<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../assets/font/iconfont.css">
    <style>
        .user-input{
            position: relative;
            display: inline-block;
            font-size: 0px;
            margin-top: 40px;
        }
        .user-input .input{
            position: relative;
            z-index: 2;
            /* 透明背景 */
            background-color: transparent;
            border: none;
            outline: none;
            width: 300px;
            padding: 8px 4px;
            border-bottom: 2px solid #ccc;
            letter-spacing: 4px;
        }
        .user-input .placeholder{
            font-size: 16px;
            color: #ccc;
            position: absolute;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            padding: 0px 4px;
            line-height: 2;
            box-sizing: border-box;
            display: flex;
            flex-flow: row nowrap;
            justify-content: space-between;
            z-index: 1;
            /* background-color: bisque; */
            transform: translate(0,0);
            transition: all 400ms ease;
        }
        .user-input .iconfont{
            color: #ccc;
            cursor: pointer;
            font-size: 16px;
            opacity: 0;
            transition: all 400ms ease;
        }
        .user-input .line{
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: 2px solid #2b93d9;
            position: absolute;
            left: 0px;
            bottom: 0px;
            width: 0%;
            z-index: 3;
            transition: all 400ms ease;
        }
        .user-input.active .line{
            width: 100%;
        }
        .user-input.active .placeholder{
            transform: translate(0,-60%);
            font-size: 12px;
            color: #2b93d9;
        }
        .user-input.active .placeholder .iconfont{
            font-size: 12px;
            opacity: 1;
        }
    </style>
    <script src="../assets/js/vue.js"></script>
</head>
<body>

    <div id="app">
        
        <div class="user-input" :class=" { 'active':isInput || !isEmpty } ">
            <input class="input" v-model="userInput" :type=" inputType " @focus=" isInput=true " @blur=" isInput=false ">
            <div class="placeholder">
                <span>Password</span>
                <span class="iconfont icon-eye" @click=" inputType = (inputType=='text'?'password':'text') "></span>
            </div>
            <hr class="line">
        </div>

    </div>

    <script>
        new Vue({
            el:"#app",
            data:{
                isInput:false,
                inputType:"password",
                userInput:""
            },
            computed:{
                isEmpty(){
                    return this.userInput.length==0
                }
            }
            
        })
    </script>
</body>
</html>